<?php defined('APP_PATH') or exit('Access Denied');?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>订单明细</title>
<link rel="stylesheet" type="text/css" href="vonuo/static/css/vonuo.css">
<script type="text/javascript" src="vonuo/static/js/jquery.min.js"></script>
<script type="text/javascript" src="vonuo/static/js/tablecolor.js"></script>
<script type="text/javascript">
var status = <?php echo $order['status'];?>;
$(document).ready(function(){
	if(status != 1 && status != 2){
		$("#kuaidi").attr("disabled","disabled");
		$("#danhao").attr("disabled","disabled");
	}
});
function check(){
	if($("#status").val() == status){
		if(status == 3){
			alert('禁止修改已失效订单！');
		}else{
			alert('请选择新的订单状态！');
		}
		return false;
	}else if($.trim($("#note").val()) == ''){
		$("#status").removeAttr('style');
		alert('必须填写修改原因！');
		$("#note").focus();
		return false;
	}
	var message = "温馨提示：\r\n变更为失效订单后将无法恢复！\r\n确定变更为已失效状态？";
	if($("#status").val() == 3 && !confirm(message)){
		return false;
	}
	$("form").attr("action","<?php echo spUrl('order','updst');?>").submit();
}
function check_wl(){
	if(status == 1 || status == 2){
		if($.trim($("#kuaidi").val()) == ''){
			alert('请填写物流公司名称！');
			$("#kuaidi").focus();
			return false;
		}
		if($.trim($("#danhao").val()) == ''){
			alert('请填写物流快递单号！');
			$("#danhao").focus();
			return false;
		}
		$("form").attr("action","<?php echo spUrl('order','updwl');?>").submit();
	}else{
		alert("未付款及已失效订单禁止修改物流信息！");
		return false;
	}
}
function check_nt(){
	if($.trim($("#note_order").val()) == ''){
			alert('请填写备注信息！');
			$("#note_order").focus();
			return false;
		}
	$("form").attr("action","<?php echo spUrl('order','updost');?>").submit();
}
</script>
</head>

<body>
<div class="gs_wraper gs_p_l0">
	<div class="tab_box">
		<table width="100%" border="0" cellpadding="0" cellspacing="0"  class="common_table">
		<form action="" method="post">
			<input type="hidden" name="id" value="<?php echo $order['id'];?>" />
			<input type="hidden" name="osta" value="<?php echo $order['status'];?>" />
			<tr><td width="100"><b>订单编号</b></td><td width="700" colspan="4"><?php echo $order['id'];?></td></tr>
			<tr><td width="100"><b>创建时间</b></td><td width="700" colspan="4"><?php echo date('Y-m-d H:i:s', $order['time']);?></td></tr>
			<tr><td width="100" rowspan="2"><b>会员明细</b></td><td>会员账号</td><td>所属分组</td><td>消费总额[元]</td><td>账户积分</td></tr>
			<tr><?php if(!empty($order['user'])){?><td><?php echo $order['user']['usercode'];?></td><td><?php echo $order['user']['ucat']['ucatname'];?></td><td><?php echo sprintf('%.2f',$order['user']['money']);?></td><td><?php echo $order['user']['jifen'];?></td><?php }else{?>
			<td colspan="4">提示：会员信息不存在！</td><?php }?></tr>
			<tr><td width="100" rowspan="<?php echo max(2, count($order['info'])+1);?>"><b>产品明细</b></td><td>[编号]产品名称</td><td>产品单价[元]</td><td>购买数量[单位]</td><td>单品总价[元]</td></tr>
			<?php if(!empty($order['info'])){foreach($order['info'] as $k=>$v){?>
			<tr <?php if($v['status']==='delete'){?>style="text-decoration:line-through;color:black;"<?php }elseif($v['status']==='nosale'){?>style="color:red;"<?php }?>>
				<td><?php echo sprintf('[%d] - %s',$k,$v['pname']);?></td><td><?php echo sprintf('%.2f',$v['price']);?></td><td><?php echo sprintf('%d - [%s]',$v['number'],$v['danwei']);?></td><td><?php echo sprintf('%.2f', $v['price']*$v['number']);?></td>
			<?php if($v['status']==='normal'){?>
				<input type="hidden" name="pid[]" value="<?php echo $k;?>" />
				<input type="hidden" name="price[]" value="<?php echo $v['price'];?>" />
				<input type="hidden" name="number[]" value="<?php echo $v['number'];?>" />
				<input type="hidden" name="pname[]" value="<?php echo $v['pname'];?>" />
				<input type="hidden" name="danwei[]" value="<?php echo $v['danwei'];?>" />
			<?php }?>
			</tr>
			<?php }}else{?>
			<tr><td colspan="4">提示：产品信息不存在！</td></tr>
			<?php }?>
			<?php if($order['needupd']){?>
			<tr><td width="100"><b>订单金额</b></td>
				<td width="350" colspan="2"><span style="text-decoration:line-through;color:black;">[原总金额]<?php echo $order['money'];?></span><span style="margin-left:10px;color:red;">[新总金额]<?php echo sprintf('%.2f', $order['totalmoney']);?></span></td>
				<td width="350" colspan="2">字体说明：</td>
			</tr>
			<?php }else{?>
			<tr><td width="100"><b>订单金额</b></td>
				<td width="350" colspan="2" style="color:black;"><?php echo $order['money'];?></td>
				<td width="350" colspan="2">字体说明：</td>
			</tr>
			<?php }?>
			<input type="hidden" name="totalmoney" value="<?php echo $order['totalmoney'];?>" />
			<tr><td width="100"><b>订单状态</b></td>
				<td width="350" colspan="2"><?php echo $odstarow[$order['status']];?></td>
				<td width="350" colspan="2"><span style="text-decoration:line-through;color:black;">[已删除]</span><span style="color:red;margin-left:10px;">[已下架]</span></td>
			</tr>
			<tr><td width="100" rowspan="2"><b>修改状态</b></td><td>选择状态</td><td>物流信息</td><td>修改原因：</td><td>备注信息：</td></tr>
			<tr><td><select class="blue_input input_w_110 f_left" <?php if($order['status']==3){?>disabled<?php }?> name="status" id="status">
			<?php foreach($odstarow as $k=>$v){?><option value="<?php echo $k;?>" <?php if($order['status']==$k){?>selected="selected"<?php }?>><?php echo $v;?></option><?php }?></select></td>
			<td>
				物流公司：<input id="kuaidi" name="kuaidi" value="<?php echo $order['kuaidi'];?>" type="text" class="blue_input input_w_175" /><br />
				快递单号：<input id="danhao" name="danhao" value="<?php echo $order['danhao'];?>" type="text" class="blue_input input_w_175" />
			</td>
			<td style="padding:10px;"><textarea cols="40" rows="4" id="note" class="blue_textarea" name="note" <?php if($order['status']==3){?>disabled<?php }?>></textarea></td>
			<td style="padding:10px;"><textarea cols="40" rows="4" id="note_order" class="blue_textarea" name="note_order"><?php echo $order['note'];?></textarea></td></tr>
			<tr class="bottom">
				<td colspan="5" align="left" valign="middle">
					<a href="javascript:;" onclick="return check();" class="btn_wei f_left">修改状态</a>
					<a href="javascript:;" onclick="return check_wl();" class="btn_wei f_left">修改物流</a>
					<a href="javascript:;" onclick="return check_nt();" class="btn_wei f_left">修改备注</a>
					<a href="<?php echo spUrl('order','odprint',array('id'=>$order['id']));?>" target="_blank" class="btn_wei f_left">打印</a>
					<a href="<?php echo spUrl('order','lis');?>" class="btn_wei f_left">返回</a>
				</td>
			</tr>
		</form>
  		</table>
	</div>
</div>
</body>
</html>